//导入ajax
import ajax from '../service/ajax.js'

export default{
    namespaced:true,
    state:{
       pestList:{},
       pestParam:{pageNo:'1',pageSize:'',pestName:'',pestHost:''},
       wormList:{},
       wormParam:{pageNo:'1',pageSize:'',wormName:'',wormSp:''},
       mouseList:{},
       mouseParam:{pageNo:'1',pageSize:'',mouseName:''}
    },
    //修改
    mutations:{
        setPestList(state,pest){
            state.pestList = pest
        },
        setPestParam(state,pest){
            state.pestParam = pest
        },
        setWormList(state,worm){
            state.wormList = worm
        },
        setWormParam(state,worm){
            state.wormParam = worm
        },
        setMouseList(state,mouse){
            state.mouseList = mouse
        },
        setMouseParam(state,mouse){
            state.mouseParam = mouse
        }

    },
    getters:{
    },
    //异步执行mutationde
    actions:{
        async findAllPest(context){
            let pestInfo = await ajax.getSubmit("/api/pest/findAllPest",context.state.pestParam)
            context.commit("setPestList",pestInfo)
            console.log(pestInfo)
            console.log(context.state.pestList)
        },
        async findName(context){
            let pestInfo = await ajax.getSubmit("/api/pest/findName",context.state.pestParam)
            context.commit("setPestList",pestInfo)
            console.log(pestInfo)
            console.log(context.state.pestList)
        },
        async findAllWorm(context){
            let wormInfo = await ajax.getSubmit("/api/worm/findAllWorm",context.state.wormParam)
            context.commit("setWormList",wormInfo)
            console.log(wormInfo)
            console.log(context.state.wormList)
        },
        async findWormName(context){
            let wormInfo = await ajax.getSubmit("/api/worm/findName",context.state.wormParam)
            context.commit("setWormList",wormInfo)
            console.log(wormInfo)
            console.log(context.state.wormList)
        },
        async findAllMouse(context){
            let mouseInfo = await ajax.getSubmit("/api/mouse/findAllMouse",context.state.mouseParam)
            context.commit("setMouseList",mouseInfo)
            console.log(mouseInfo)
            console.log(context.state.mouseList)
        },
        async findMouseName(context){
            let mouseInfo = await ajax.getSubmit("/api/mouse/findName",context.state.mouseParam)
            context.commit("setMouseList",mouseInfo)
            console.log(mouseInfo)
            console.log(context.state.mouseList)
        }
    }
}